const base = require('../base/baseObj')
const con = require('../../config/const')

// 获取get参数
const getParam = (req, res, next) => {
    let query = req.param('query', '')
    if(query === ''){
        res.json( base.param_err(query, '没有找到query参数') )
    }
    try{
        query = JSON.parse(query)
    }catch(e){
        res.json( base.param_err(query, 'query参数不能转为json对象:' + e.message) )
    }

    let successStr = (req.param('success', con.SUCCESS_STATUS)) + ''
    let successArr = successStr === '' ? [] : successStr.split(',')
    return {query: query, successArr: successArr}
}



module.exports = getParam